<?php

namespace App\Http\Controllers\Admin;

use App\Services\UploadService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class UploadApiController extends Controller
{

    private $service;

    public function __construct(UploadService $service)
    {
        $this->service = $service;
    }

    public function fileupload($disk = '', Request $request, $form_file_name = 'imgFile')
    {
        if ($disk) {
            $this->service->disk($disk);
        }
        $url = $this->service->formUpload($form_file_name, Auth::id(), $request);
        return response()->json(['error' => 0, 'url' => $url], 200);
    }

}
